home *** CD-ROM | disk | FTP | other *** search
/ Freelog 117 / FreelogNo117-OctobreNovembre2013.iso / Programmation / jedit / jedit5.1.0install.exe / {app} / macros / Editing / Go_to_Column.bsh < prev    next >
Text File  |  2013-07-28  |  1KB  |  58 lines

  1. /*
  2.  * Go_to_Column.bsh - a BeanShell macro for the jEdit text
  3.  * editor - Prompts the user for a column position on the
  4.  * current line, then moves the caret there.
  5.  *
  6.  * Copyright (C) 2003 Ollie Rutherfurd <oliver@rutherfurd.net>
  7.  *
  8.  * $Id: Go_to_Column.bsh 21353 2012-03-14 09:46:51Z jojaba_67 $
  9.  */
  10.  
  11. //Localization
  12. final static String ColumnBeforeLabel   = jEdit.getProperty("macro.rs.GoToColumn.ColumnBefore.label",  "Column (between 1 and");
  13. final static String ColumnAfterLabel   = jEdit.getProperty("macro.rs.GoToColumn.ColumnAfter.label",  "):");
  14.  
  15. //Process
  16. goToColumn()
  17. {
  18.     line = textArea.getCaretLine();
  19.     len = textArea.getLineLength(line) + 1;
  20.     while(true)
  21.     {
  22.         col = Macros.input(view, ColumnBeforeLabel + " " + len + " " + ColumnAfterLabel);
  23.         if(col == null)
  24.             return;
  25.         else
  26.         {
  27.             try
  28.             {
  29.                 col = Integer.parseInt(col);
  30.                 if(col >= 1 && col <= len)
  31.                 {
  32.                     lineStartOffset = textArea.getLineStartOffset(line);
  33.                     textArea.setCaretPosition(lineStartOffset + (col-1));
  34.                     textArea.requestFocus();
  35.                     return;
  36.                 }
  37.             }catch(NumberFormatException e){
  38.             }
  39.         }
  40.     }
  41. }
  42.  
  43. goToColumn();
  44.  
  45. /*
  46.     Macro index data (in DocBook format)
  47.  
  48. <listitem>
  49.     <para><filename>Go_to_Column.bsh</filename></para>
  50.     <abstract><para>
  51.         Prompts the user for a column position on the 
  52.         current line, then moves the caret there.
  53.     </para></abstract>
  54. </listitem>
  55.  
  56. */
  57.  
  58.